<?php
class car {

    private $_params;

    public function __construct($params) {
        $this->_params = $params;
    }

    /**
     * Haal auto's op
     * @return array
     */
    public function getAction() {

        $stmt = ENV::$db->query("SELECT * FROM car_car ORDER BY car_id");
        $cars = $stmt->fetchAll(PDO::FETCH_ASSOC);

        return $cars;
    }

    /**
     * Reserveer een auto
     */
    public function bookAction() {

        $sql = "INSERT INTO rese_reservation SET rese_car_id = ?, rese_name = ?, rese_time = ?, rese_price = ?, rese_telephone = ?";
        $q = ENV::$db->prepare($sql);
        $q->execute(array(
            $this->_params["rese_car_id"],
            $this->_params["rese_name"],
            mktime(),
            $this->_params["rese_price"],
            $this->_params["rese_telephone"]
        ));
    }
}